package com.liuyingxing.javaSpringCloudAccount.controller;

import com.liuyingxing.entity.account.Menu;
import com.liuyingxing.javaSpringCloudAccount.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * @File MenuController.java
 * @Auth liuxing
 * @Date 2021/8/26 10:20
 * @Email liuxing997@foxmail.com
 */
@RestController
@RequestMapping("/api/account/")
public class MenuController {

    @Autowired
    private MenuService menuService;

    /**
     * 获取所有菜单信息
     * 127.0.0.1/api/menus ---- get
     */
    @GetMapping("/menus")
    public List<Menu> getAllMenus() {
        return menuService.getAllMenus();
    }

    /**
     * 根据用户ID获取菜单信息
     * 127.0.0.1/api/menus/1 ---- get
     */
    @GetMapping("/menus/{userId}")
    public List<Menu> getMenusByUserId(@PathVariable int userId) {
        return menuService.getMenusByUserId(userId);
    }

}
